import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore(
  'user',
  () => {
    const userid = ref('')
    const username = ref('')
    const setUser = (userInfo) => {
      userid.value = userInfo.userid
      username.value = userInfo.username
    }
    const clearUser = () => {
      userid.value = ''
      username.value = ''
    }
    return {
      userid,
      username,
      setUser,
      clearUser
    }
  },
  {
    persist: true
  }
)
